package com.briup.jd2511.jd2511_product_source.controller;

import com.briup.jd2511.jd2511_product_source.pojo.QuarantineRegistration;
import com.briup.jd2511.jd2511_product_source.result.Result;
import com.briup.jd2511.jd2511_product_source.service.QuarantineRegistrationService;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "检疫登记模块")
@RestController
@RequestMapping("/quarantineRegistration")
public class QuarantineController {

    @Autowired
    private QuarantineRegistrationService qrService;

    @GetMapping
    @Operation(summary = "分页+条件查询检疫记录")
    @Parameters(value = {
            @Parameter(name = "pageName",description = "页码"),
            @Parameter(name = "pageSize",description = "每页数量"),
            @Parameter(name = "grMechanism",description = "检疫机构"),
            @Parameter(name = "bQualified",description = "检疫结果")
    })
    public Result getAllByConditionByPage(@RequestParam(defaultValue = "1") Integer pageName,
                                          @RequestParam(defaultValue = "10") Integer pageSize,
                                          @RequestParam(required = false) String grMechanism,
                                          @RequestParam (required = false) String bQualified ){
        PageInfo<QuarantineRegistration> pageInfo = qrService.findByPage(pageName,pageSize,grMechanism,bQualified);
        return Result.success(pageInfo);
    }

    @PostMapping("/saveOrUpdate")
    @Operation(summary = "添加/修改检疫登记信息")
    public Result saveOrUpdate(@RequestBody QuarantineRegistration qr){
        qrService.saveOrUpdate(qr);
        return Result.success();
    }



}
